package com.heima.article.listentr;

import com.alibaba.fastjson.JSON;
import com.heima.article.service.ArticleService;
import com.heima.common.constants.KafkaConstans;
import com.heima.model.article.pojos.ApArticleConfig;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @author Xiao
 * @version 1.0
 * @description kafka消息监听器
 * @date 2021/11/26
 */
@Component
public class ArticleListener {
    @Autowired
    private ArticleService articleService;
    @KafkaListener(topics = KafkaConstans.WM_NEWS_DEL_OR_DOWN_TOPIC)
    public void delOrDown(String message) {
        if (StringUtils.isNotBlank(message)) {
            articleService.delOrDownArticle(JSON.parseObject(message, ApArticleConfig.class));
        }
    }
}
